program udaleniefromend;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  pelement=^element
  element=record
          value:integer;
          next:pelement;
        end;

procedure add (var head:pelement; num:integer);
  var tmp:pelement;
  begin
    tmp:=head
    new(head);
    head^.next:=tmp;
    head^.value:=num;
  end;

function DeleteFromTheEndING (var head:pelement; num:integer);
  var
    current : pelement;
  begin
    current:=head
    if (head<>nil) then begin
      while (current^next<>nil) do
      begin
        current:=current^.next;
      end;
      DeleteFromTheEndING:=current^.value;
      dispose(current^);
      current^:=nil;
    end;

var
  n, i, a : integer;

begin
  assignfile(fin, 'input.txt');
  reset(fin);
  readln(input, n);
   for i:=1 to n do
    begin


end.
